<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('woc' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$wid = isset( $_GET['wid'] ) ? $_GET['wid']:  0;
$modulname = "Personalia _BN_ Waktu Kerja _BN_ Work On Call";
if( $_SERVER['REQUEST_METHOD'] == "POST" ){
	if($task == 'edit'){
		$nid = woc_submit($id);
		if($id == 0)
			my_direct('index.php?com=woc&task=detail&id='.$nid);
		else
			my_direct('index.php?com='.$_GET['com']);
	}elseif($task == 'edit_detail_page'){
		woc_detail_submit($wid,$id);
		generate_my_web("Updated!!", '','plain.php');
		exit;
		my_direct('index.php?com=woc&task=detail&id='.$id);
	}
}else{
	if($task == 'delete'){ // DELETE ITEM	
		remove_woc($id);
		my_direct('index.php?com='.$_GET['com']);
	}elseif($task=='edit'){
		$pagename = ($id>0)? $modulname." _BN_ Perubahan Data" : $modulname." _BN_ Tambah Data";
		$content = woc_form($id);
	}elseif($task=='detail'){
		$pagename = $modulname; 
		load_facebox_script();	
		$content =  woc_detail_list($id); 	
	}elseif($task=='edit_detail'){
		facebox_page( 'index.php?com='.$_GET['com'].'&task=edit_detail_page&wid='.$_GET['wid'].'&id='.$_GET['id'], ($id >0 ? "Ubah Data ": "Tambah Data"),325);
	}elseif($task=='edit_detail_page'){
		$pagename = ($id>0)? $modulname." _BN_ Perubahan Data" : $modulname." _BN_ Tambah Data";
		$content = woc_detail_form($wid,$id);
		generate_my_web($content, $pagename ,"plain.php");
		exit;
	}elseif($task=='delete_detail'){
		delete_woc_detail_woc($id);
		my_direct($_SERVER['HTTP_REFERER']);		
	}else{
		$pagename = $modulname; 
		$content =  woc_list(); 
	}
}
generate_my_web($content, $pagename );